<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="维修管理" libs=["table"]/>
<div class="container-div" id="_app">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <@f.form id="module-form">

            <!--我们在body中加入一个div，里面放入一个table-->
            <div style="display:none" id="test">
                <h4>高级查询</h4>
                <hr>
                <table class="table table-striped">
                    <tbody>
                    <tr>
                        <td><@ctx.i18n text = "设备编码"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentCode2"  placeholder="请输入设备名称"></td>
                        <td><@ctx.i18n text = "设备名称"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentName2"  placeholder="请输入设备名称"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "设备型号"/>：</td>
                        <td><input type="text" class="form-control" name="equipmentModel"  placeholder="请输入设备型号"></td>
                        <td><@ctx.i18n text = "单位"/>：</td>
                        <td><input type="text" class="form-control" name="meteringUnit"  placeholder="请输入单位"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "维修费用"/>：</td>
                        <td><input type="text" class="form-control" name="repairMoney"  placeholder="请输入维修费用"></td>
                        <td><@ctx.i18n text = "维修状况"/>：</td>
                        <td><input type="text" class="form-control" name="repairStatus"  placeholder="请输入设备编号"></td>
                    </tr>
                    <tr>
                        <td><@ctx.i18n text = "故障原因"/>：</td>
                        <td><input type="text" class="form-control" name="faultReason"  placeholder="请输入故障原因"></td>
                        <td><@ctx.i18n text = "备注"/>：</td>
                        <td><input type="text" class="form-control" name="remark"  placeholder="请输入备注"></td>
                    </tr>
                    <tr>
                        <td class="select-time" colspan="4"><label>送修日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect" style="width: 150px" ><label>--</label><input type="text" name="endTime" class="layui-input" placeholder="请输入选择时间" id="timeSelect2" style="width: 150px"></td>
                    </tr>
                    <tr>
                        <td class="select-time" colspan="4"><label>维修日期：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label><input type="text" name="beginTime2" class="layui-input" placeholder="请输入选择时间" id="timeSelect3" style="width: 150px" ><label>--</label><input type="text" name="endTime2" class="layui-input" placeholder="请输入选择时间" id="timeSelect4" style="width: 150px"></td>
                    </tr>
                    </tbody>
                    <tfoot>
                    <tr>
                        <td colspan="2" align="center"><a class="btn btn-primary btn-rounded btn-sm" id="search" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a></td>
                        <td colspan="2" align="center"><a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a></td>
                    </tr>
                    </tfoot>
                </table>
            </div>
            <!--里面放入一个table-->

            <div class="select-list">
                <ul>
                    <li >
                        <@ctx.i18n text = "设备编码"/>：
                        <input type="text" class="form-control" name="equipmentCode"/>
                    </li>
                    <li >
                        <@ctx.i18n text = "设备名称"/>：
                        <input type="text" class="form-control" name="equipmentName"/>
                    </li>
                    <li>
                        <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>  <@ctx.i18n text = "查询"/></a>
                        <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i> <@ctx.i18n text = "重置"/></a>
                        <a class="btn btn-primary btn-rounded btn-sm" id="searchall"><i class="fa fa-search"></i>  <@ctx.i18n text = "高级查询"/></a>
                    </li>
                    <!--<li>-->
                    <!--<@shiro.hasPermission name="sys:user:export">-->
                    <!--<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.exportExcel()">-->
                        <!--<i class="fa fa-download"></i> 导出-->
                    <!--</a>-->
                    <!--</@shiro.hasPermission>-->
                    <!--</li>-->
                </ul>
            </div>
        </@f.form>
    </div>
    <@table id="bootstrap-table">
    <@shiro.hasPermission name="bus:scrap:add">
    <a class="btn btn-success" onclick="opt.operate.addTab(0)">
        <i class="fa fa-plus"></i> <@ctx.i18n text = "新增"/>
    </a>
</@shiro.hasPermission>
<@shiro.hasPermission name="bus:scrap:edit">
<a class="btn btn-danger multiple disabled" onclick="opt.operate.editTab()">
    <i class="fa fa-edit"></i> <@ctx.i18n text = "修改"/>
</a>
</@shiro.hasPermission>
<@shiro.hasPermission name="bus:scrap:del">
<a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
    <i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/>
</a>
</@shiro.hasPermission>

<@shiro.hasPermission name="sys:user:export">
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.exportExcel()">
    <i class="fa fa-download"></i> 导出
</a>
<a class="btn btn-info"  id="licSelect">
    <i class="fa fa-upload"></i> 导入
</a>
</@shiro.hasPermission>
</@table>

</div>
<@footer>
<script type="text/javascript">
    var statusDatas = ${dict.getDictListJson('project_status')};
    var statusDatas1 = ${dict.getDictListJson('project_type')};
    var editFlag = "${permission.hasPermi("bus:repair:edit")}";

    var delFlag = "${permission.hasPermi('bus:repair:del')}";
    var listFlag = "${permission.hasPermi("bus:repair:add")}";
    // var categoryDatas = ${dict.getDictListJson('sys_bpm_category')};
    var prefix = baseURL + "bus/repair";

    $(function() {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            clickToSelect: true,
            sortName: "id",
            delUrl: prefix + "/del",
            addUrl: prefix + "/add",
            editUrl: prefix + "/edit/{id}",//认领箱
            exportUrl: prefix + "/export",
            importUrl: prefix + "/import",
            uniqueId: 'id' , /* 唯一ID */
            modalName: "维修管理",
            columns: [
                // {field: 'selectItem', radio: true},
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                        return $.table.serialNumber(index);}},
                // {field : 'id',title : '<@ctx.i18n text = "编号"/>'},
                {field : 'equipmentCode',title : '<@ctx.i18n text = "设备编码"/>'},
                {field : 'equipmentName',title : '<@ctx.i18n text = "设备名称"/>'},
                {field : 'equipmentModel',title : '<@ctx.i18n text = "设备型号"/>'},
                {field : 'meteringUnit',title : '<@ctx.i18n text = "单位"/>'},
                {field : 'sendTime',title : '<@ctx.i18n text = "送修日期"/>'},
                {field : 'repairTime',title : '<@ctx.i18n text = "维修日期"/>'},
                {field : 'repairMoney',title : '<@ctx.i18n text = "维修费用"/>'},
                {field : 'repairStatus',title : '<@ctx.i18n text = "维修状况"/>'},
                {field : 'faultReason',title : '<@ctx.i18n text = "故障原因"/>'},
                {field : 'remark',title : '<@ctx.i18n text = "备注"/>'},
                {title:"<@ctx.i18n text = "操作"/>",align: 'left',class:'action',formatter: function(value, row, index) {
                        var actions = [];
                        // actions.push('<a class="" href="javascript:void(0)" title="<@ctx.i18n text = "关联流程表单"/>" onclick="taskFrom(\'' + row.id + '\')"><i class="fa icon-organization"></i></a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick=" opt.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i><@ctx.i18n text = "编辑"/></a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> <@ctx.i18n text = "删除"/></a>');
                        return actions.join('');
                    }}
            ]
        };
        $.table.init(options);
    });




    /* 用户管理-重置密码 */
    function upload() {
        var options = {
            title: "选择文件",
            width: "800",
            height: "300",
            url: prefix + '/selectFile',
            callBack: DeptDoSubmit
        };
        opt.modal.openOptions(options);
    }

    function DeptDoSubmit(index, layero) {

        var body = layer.getChildFrame('body', index);
        console.log(body);
        importTable(body.find('#fileName').val());
        layer.close(index);
    }

    /*导入表结构*/
    function importTable(url) {

        var importTableUrl = prefix + "/upload/";

        /*opt.modal.open("导入表结构", importTableUrl);*/
        opt.operate.post(importTableUrl,{url: url});
    }

    function upload_abort(){
        document.getElementById("files").click();
        if(files == ""){
            alert("请选择要上传的文件");
        }else{
            //扩展名的文件名
            var files = document.getElementById("files").value;
            //扩展名的文件名
            var bbb=files.lastIndexOf(".");
            var ccc=files.substring(bbb+1);
            if(ccc=='xlsx'){
                $("#uploadForm").submit();
                setTimeout("fun()",1500);
            }else{
                alert("请选择.xlsx文件");
            }
        }


    }


    /* 挂起流程定义 */
    function disable(id) {
        opt.modal.confirm("确认要挂起流程定义吗？", function() {
            opt.operate.post(prefix + "/status", { "deploymentId": id, "status": 1 });
        })
    }

    /* 激活流程定义 */
    function enable(id) {
        opt.modal.confirm("确认要激活流程定义吗?", function() {
            opt.operate.post(prefix + "/status", { "deploymentId": id, "status": 0 });
        })
    }

    function taskFromEdit(id) {
        // opt.modal.confirm("确认要删除流程定义吗?", function() {
        //  opt.modal.openTab(prefix + "/edit", { "id": id});
        console.log("1111111111");
        console.log(id);
        console.log("11111111");
        opt.modal.openTab("认领修改",prefix + "/edit/"+id);
        // })
    }

    function taskFrom(id){


        opt.modal.openTab("关联表单",prefix + "/taskfrom/"+id);
    }

    /*预览*/
    function preview(id) {
        var options = {
            url: prefix + "/preview/" + id,
            title: '<i class="fa icon-picture"></i> <@ctx.i18n text = "流程图"/>',
            btn:['<i class="fa fa-close"></i> '+$.i18n.prop("取消")],
            width: $(top.window).width() - 300,
            height: $(top.window).height() - 400
        };
        opt.modal.openMainWin(options);
    }

    /*预览XML*/
    function  preXml(id){
        var options = {
            url: prefix + "/xml/" + id,
            title:'<i class="fa fa-file-code-o"></i> <@ctx.i18n text = "BPMN2.0流程文件"/>',
            btn:['<i class="fa fa-close"></i> '+$.i18n.prop("取消")],
        };
        opt.modal.openMainWin(options);
    }

    /*生成代码*/
    function xmlDownload(id,name) {
        opt.modal.confirm("确定要下载[" + name + "]流程文件吗?", function() {
            location.href = prefix + "/download/" + id;
            opt.modal.msg('执行成功,正在下载请稍后…');
        })
    }
    $('#licSelect').click(function(){
        opt.layer.open({
            type: 1,
            area: ['580px', '180px'],
            title: '<i class="fa fa-upload"></i> 导入文件 <i class="fa fa-info-circle" style="color: red"></i>!',
            shade: 0.3,
            shadeClose: true,
            resize: false,
            scrollbar: true,
            content: opt.template('upload'),
            btn: ['<i class="fa fa-check"></i> 上传',
                '<i class="fa fa-remove"></i> 取消'],
            btn1: function(index, layero){
                var form = {
                    inputForm: layero.find('#inputForm'),
                    f: layero.find('#f').val()
                };
                if (form.f == '' || !opt.common.endWith(form.f, '.xlsx'||!opt.common.endWith(form.f, '.xls'))){
                    opt.warning("<@ctx.i18n text = "文件不正确，请选择后缀为 . xls和xlsx的文件。"/>");
                    return false;
                }
                var formdata = new FormData();
                var file = layero.find('#f')[0].files[0];
                formdata.append("files", file);
                opt.common.sendAjax({
                    url: prefix + "/upload",
                    data: formdata,
                    type: "POST",
                    processData: false,
                    contentType: false,
                    success: function(result) {
                        if(result.code == opt.variable.web_status.SUCCESS){
                            opt.layer.closeAll();
                            opt.success("<@ctx.i18n text = "文件上传成功!"/>");
                            location.reload();
                        }else{
                            opt.error(result.msg);
                        }
                    }
                });
                return true;
            }
        });
    });
</script>
<!--<script id="check" type="text/template">-->
<!--    <form id="inputForm" method="post" enctype="multipart/form-data" class="form-horizontal mt20 mb10">-->
<!--        <label class="control-label col-xs-5" >-->

<!--            <button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "出库"/></button>&nbsp;-->
<!--            <button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "取消"/></button>-->


<!--        </label>-->
<!--        &lt;!&ndash;<div class="col-xs-7">&ndash;&gt;-->
<!--        &lt;!&ndash;<button type="button" class="btn btn-sm btn-primary" onclick="opt.form.submit()"><i class="fa fa-check"></i><@ctx.i18n text = "保存"/></button>&nbsp;&ndash;&gt;-->
<!--        &lt;!&ndash;<button type="button" class="btn btn-sm btn-danger" onclick="opt.modal.closeTab()"><i class="fa fa-reply-all"></i><@ctx.i18n text = "关闭"/></button>&ndash;&gt;-->
<!--        &lt;!&ndash;</div>&ndash;&gt;-->
<!--    </form>-->

<!--</script>-->
<script id="upload" type="text/template">
    <form id="inputForm2" method="post" enctype="multipart/form-data" class="form-horizontal mt20 mb10">
        <label class="control-label col-xs-5"><span class="required">*</span> 导入文件：</label>
        <div class="col-xs-7">
            <input type="file" id="f" name="f" style="padding-top: 4px;"/>
        </div>
    </form>
</script>

<script>
    /*弹出层*/
    $('#searchall').on('click', function(){
        // layer.msg('hello');
        layer.open({
            type: 1,
            title:'组合查询',
            area: ['600px', '450px'],
            content: $("#test"),
            shade:0.0,
            btn: ['关闭'], //只是为了演示,
            btn2: function(){
                layer.closeAll();
            }
        });
    });
    /*弹出层点击查询按钮关闭弹出层*/
    $('#search').on('click',function () {
        layer.closeAll()
    });

    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect2'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect3'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
    /*弹出层时间选择控件*/
    layui.use('laydate', function(){
        var laydate = layui.laydate;
        laydate.render({
            elem: '#timeSelect4'  // 输出框id
            ,format: 'yyyy-MM-dd'
            ,trigger:'click'
        });
    });
</script>
</@footer>
</@pageTheme>